<%@page import="java.util.Map"%>
<%@page import="helpers.EscapeCharsHelper"%>
<%@page import="entities.ApplicationTemplate"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.TreeMap"%>
<%@page import="helpers.UrlHelper"%>

<%
TreeMap<String, String> check = (TreeMap<String, String>) request.getAttribute("check");
String success = (String) request.getAttribute("success");
ApplicationTemplate template = (ApplicationTemplate) request.getAttribute("template");
String form = (String) request.getAttribute("form");
%>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:include page="/admin/layouts/header.jsp" />

<script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="/admin/js/custom/application_template_form.js"></script>
		
					<!-- Content Area -->
                	<div id="da-content-area">
                		<jsp:include page="/admin/elements/message_box.jsp" />
                        
                        <div class="grid_1">
                        	<div class="da-panel-widget">
                            	<h1>Template Files</h1>
                            	
		                        <ul class="list-template">
		                        	<li><label>Header Page</label> <a title="Edit" class="headerPageValue" id="header" href="#">(Edit)</a></li>
		                        	<li><label>Footer Page</label> <a title="Edit" class="footerPageValue" id="footer" href="#">(Edit)</a></li>
			                    	<li><label>Homepage</label> <a title="Edit" class="homePageValue" id="homePage" href="#">(Edit)</a></li>
			                    	<li><label>Contact</label> <a title="Edit" class="contactPageValue" id="contactPage" href="#">(Edit)</a></li>
			                    	<li><label>Static Page</label> <a title="Edit" class="staticPageValue" id="staticPage" href="#">(Edit)</a></li>
			                    	<li><label>Search</label> <a title="Edit" class="searchPageValue" id="searchPage" href="#">(Edit)</a></li>
			                    	<li><label>Library</label> <a title="Edit" class="libraryPageValue" id="libraryPage" href="#">(Edit)</a></li>
			                    </ul>
			                    
	                    		<a href="/admin/apptemplate/restore/<%=template.getId() %>" class="restore-default">(Restore Template Default)</a>
	                    		
	                    		<form class="da-form" method="post">
                                   	<div class="da-form-block">
                                   		<div class="da-form-row">
                                               <label>Title <span class="required">*</span></label>
                                               <div class="da-form-item large">
                                                   <input type="text" name="title" value="<%=template.getTitle() %>" class="<%=check.get("title") != null ? "error" : "" %>"/>
                                                   <% if (check.get("title") != null) { %>
                                                   <span class="errorMessage"><%=check.get("title") %></span>
                                                   <% } %>
                                               </div>
                                           </div>
                                           
                                           <div class="da-form-row">
                                               <label>Description <span class="required">*</span></label>
                                               <div class="da-form-item large">
                                                   <textarea cols="auto" rows="auto" name="description" class="<%=check.get("description") != null ? "error" : "" %>" ><%=template.getDescription() %></textarea>
                                                   <% if (check.get("description") != null) { %>
                                                   <span class="errorMessage"><%=check.get("description") %></span>
                                                   <% } %>
                                               </div>
                                           </div>
                                           
                                           <div class="da-form-row">
                                               <label>Base Url</label>
                                               <div class="da-form-item small">
                                                   <%=template.getBaseUrl() %>
                                               </div>
                                           </div>
                                           
                                           <div class="hidden" style="display: no">
						                    	<textarea id="headerPageValue" name="header" style="display: none;"><%=template.getHeader() %></textarea>
												<textarea id="footerPageValue" name="footer" style="display: none;"><%=template.getFooter() %></textarea>
												<textarea id="homePageValue" name="home" style="display: none;"><%=template.getHome() %></textarea>
												<textarea id="contactPageValue" name="contact" style="display: none;"><%=EscapeCharsHelper.forHTML(template.getContact()) %></textarea>
												<textarea id="staticPageValue" name="staticPage" style="display: none;"><%=template.getStaticPage() %></textarea> 
												<textarea id="searchPageValue" name="search" style="display: none;"><%=EscapeCharsHelper.forHTML(template.getSearch())%></textarea>
												<textarea id="libraryPageValue" name="libraryArticle" style="display: none;"><%=template.getLibrary()%></textarea>
											</div>
                                           
                                           <div class="da-button-row save-change">
                                           	<input type="submit" value="Submit" class="da-button blue left" />
                                        	<input type="reset" value="Reset" class="da-button gray" />
                                        </div>
                                       </div>
                                   </form>
	                    		
	                    		
                            </div>
                        </div>
                        
                        <div class="grid_3">
                        	<div class="da-panel-widget">
                        		<div class="editor-area">
	                            	<h3>Edit <span class="label-page-edit"></span></h3>
	                            	<div class="template-panel">
			                        	<button class="da-button blue">Apply</button>
			                        </div>
			                        <br>
			                    	<textarea name="pageValue" id="pageValue" rows="20" cols="118" class="hide" ></textarea>
									<div>
										<div id="template-editor"></div>
									</div>
								</div>
                            </div>
                        </div>
                		
                	</div>

<jsp:include page="/admin/layouts/footer.jsp" />